package com.waterfairy.http.utils;

import okhttp3.FormBody;
import okhttp3.RequestBody;

/**
 * @user water_fairy
 * @mail 995637517@qq.com
 * @date 2021/8/5 4:55 下午
 * @info
 */
public class FormBodyUtils {
    public static final String MEDIA_TYPE = "application/json; charset=utf-8";

    public static String getParams(RequestBody requestBody) {
        FormBody formBody = (FormBody) requestBody;
        int size = formBody.size();
        StringBuilder buffer = new StringBuilder();
        for (int i = 0; i < size; i++) {
            if (i > 0) buffer.append('&');
            buffer.append(formBody.name(i));
            buffer.append('=');
            buffer.append(formBody.value(i));
        }
        return buffer.toString();
    }
}
